home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
printing
/
ds2v4052.zip
/
FORPGMRS.EXE
/
lha
/
TDSP.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-28
|
3KB
|
84 lines
//====================================================================//
// TDSP.CPP - demonstrates the usage of PRTDRV.OBJ //
// //
// (c) Budget Software Company 1992 //
// //
//====================================================================//
#include <dos.h>
#include <string.h>
#define LPT1 4
#define COM1 0
// declare routines
extern "C"
{
void far dspler_init_me();
void far dspler_despool();
}
char *printme = "This is a string to print. \n";
//
void printstuff(unsigned char port)
{
//
// The following code shows how to send multiple bytes. This method
// should be used when coming off of the Timer interrupt. Normally,
// you exit the Timer interrupt after this call, and continue on at
// the next Timer interrupt (adjusting your print stream pointer
// according to how many bytes were actually sent). This demonstration
// continues to call the print function until the stream is all printed.
//
unsigned int segm = FP_SEG(printme);
unsigned int off = FP_OFF(printme);
int workint;
int anint = strlen(printme); // number of bytes to print
unsigned char returnAL;
unsigned char aushort = (unsigned char)anint; // convert to 8 bits
do
{
asm mov cl,aushort // number of bytes to print
asm mov bl,port
asm mov bh,2 // indicate source as Timer interrupt
asm push bx
asm push cx
asm mov ax,off // DX:AX point to stream
asm mov dx,segm
asm pop cx
asm pop bx
dspler_despool();
asm mov returnAL,al // AL has the number of bytes printed
workint = (int)returnAL;
aushort = aushort - returnAL; // adjust number of bytes left to print
off += workint; // adjust pointer to stream
}
while(aushort != 0);
}
int main()
{
asm mov ah,0 // All 8 ports: don't send direct to port.
asm mov al,0ffh // All 8 ports: use BIOS.
dspler_init_me(); // Initialize PRTDRV.
//
// The following code shows how to send a single byte to print.
// This method should be used when coming off of an IRQ, or off of
// idle time.
//
asm mov cl,1 // send 1 byte
asm mov ch,'a' // character to send
asm mov bl,4 // port LPT1
asm mov bh,0 // indicate source was IRQ
dspler_despool();
//
// print to LPT1
//
printstuff(LPT1);
//
// print to COM1
//
printstuff(COM1);
//
return 0;
}